package com.ruoyi.web.controller.tool;

import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import org.gitlab.api.GitlabAPI;
import org.gitlab.api.models.GitlabMergeRequest;

import java.io.IOException;

public class GitlabTest {
  public static void callWithMessage()
      throws NoApiKeyException, ApiException, InputRequiredException {
      // 使用gitlab获得变更代码内容
      String hostUrl = "http://localhost:8200";
      String token = "vwxyRQdL_mhEvQZFCsxV";
      GitlabAPI gitlabAPI = GitlabAPI.connect(hostUrl, token);
      try {
          GitlabMergeRequest mergeRequestChanges = gitlabAPI.getMergeRequestChanges(2, 2);
          System.out.println(mergeRequestChanges.getChanges());
      } catch (IOException e) {
          throw new RuntimeException(e);
      }
  }


  public static void main(String[] args){
        try {
          callWithMessage();
        } catch (ApiException | NoApiKeyException | InputRequiredException e) {
          System.out.println(e.getMessage());
        }
        System.exit(0);
  }
}
